/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_ora_stmt_add_column_metadata.c                     */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/22 by geyh                                 */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../../src/module/oracle/config.h"
#include "../../test_ora_comm.h"
#include <apmtest_comm.h>
#include <oracle/comm/ora_stmt.h>



static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}


static void __case1(void)
{
    Conntrack *p_st_conn = NULL;
    Sql_statement *p_st_stmt = NULL;
    Ora_metadata st_ora_metadata;
    int i_ret = 0;
    
    CU_ASSERT_EQUAL(test_ora_create_ct(&p_st_conn, TEST_ORA_SRC_IP, TEST_ORA_DST_IP, TEST_ORA_SRC_PORT, TEST_ORA_DST_PORT), FR_SUCC);

//    i_ret = ora_create_new_stmt(p_st_conn, &p_st_stmt);
    
    i_ret = ora_set_new_stmt(p_st_conn, &p_st_stmt);
    
    CU_ASSERT_PTR_NOT_NULL(p_st_stmt);
    CU_ASSERT_EQUAL(i_ret, FR_SUCC);
    
    st_ora_metadata.s_oacdty = 1;
    st_ora_metadata.s_oacflg = 1;
    st_ora_metadata.s_oacpre = 1;
    st_ora_metadata.s_oacscl = 1;
    st_ora_metadata.i_oacmxl = 1;
    st_ora_metadata.i_oacmal = 1;
    st_ora_metadata.i_oacfl2 = 1;
    st_ora_metadata.i_oacvsn = 1;
    st_ora_metadata.i_oaccsi = 1;
    st_ora_metadata.s_oaccsfrm = 1;
    st_ora_metadata.i_oacmxlc = 1;
    st_ora_metadata.i_oacmxl = 1;
    
    i_ret = ora_stmt_add_column_metadata(p_st_stmt, st_ora_metadata);
    
    CU_ASSERT_EQUAL(i_ret, FR_SUCC);
    ora_free_req_stmt(p_st_conn);
    
    test_ora_destroy_ct(&p_st_conn);
    return;
}



int add_suite_ora_stmt_add_column_metadata(void)
{
    CU_pSuite pSuite = NULL;
    
    if ((pSuite = CU_add_suite(MODULE_NAME" ora_stmt_add_column_metadata()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;
    
    CU_add_test(pSuite, "case1", __case1);
    
    return FR_SUCC;
}
